cmake_minimum_required(VERSION 3.10)


mark_as_advanced(
    BUILD_GMOCK BUILD_GTEST BUILD_SHARED_LIBS
    gmock_build_tests gtest_build_samples gtest_build_tests
    gtest_disable_pthreads gtest_force_shared_crt gtest_hide_internal_symbols
)
if (MSVC)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif(MSVC)
macro(faiss_add_test TESTNAME)
    # create an exectuable in which the tests will be stored
    add_executable(${TESTNAME} ${ARGN})
    # link the Google test infrastructure, mocking library, and a default main fuction to
    # the test executable.  Remove g_test_main if writing your own main function.
    target_link_libraries(${TESTNAME} faiss gtest gmock gtest_main)
    # gtest_discover_tests replaces gtest_add_tests,
    # see https://cmake.org/cmake/help/v3.10/module/GoogleTest.html for more options to pass to it
    gtest_discover_tests(${TESTNAME}
        # set a working directory so your project root so that you can find test data via paths relative to the project root
        WORKING_DIRECTORY ${PROJECT_DIR}
        PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${PROJECT_DIR}"
    )
    set_target_properties(${TESTNAME} PROPERTIES FOLDER tests)
endmacro()

File(GLOB faiss_test_cpp ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
if(WIN32)
	list(REMOVE_ITEM faiss_test_cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_ondisk_ivf.cpp)
	list(REMOVE_ITEM faiss_test_cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_merge.cpp)
endif(WIN32)
faiss_add_test(faiss_test ${faiss_test_cpp})
